<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/9/5
 * Time: 15:43
 */
namespace app\admin\model;

use think\Db;
use think\Model;

class Goods extends Model
{
    //设置当前模型对应数据表名称
    protected $table = 'am_goods';

    //查询用户表所有数据
    public function seleteAll()
    {
        $result = $this->field('*')->select();
        return $result;
    }

    //添加商品信息
    public function addGoods($data)
    {
        $res = $this->data($data)->save();
        return $res;
    }

    //修改商品信息
    public function updateGoods($id)
    {
        $res = $this->field('*')->where('id='.$id)->find();
        return $res;
    }

    //更新商品信息
    public function editGoods($data,$id)
    {
        $res = $this->allowField('*')->save($data,['id'=>$id]);
        return $res;
    }

    //删除商品信息
    public function deleteGoods($id)
    {
        $res = $this->where('id',$id)->delete();
        return $res;
    }
}